$(function() {
	var qb = "#qianbao";
	var luk="/index.html?kechengid=";
	var lup="/index.html?peixunid=";
	var jiage=Url["jiage"];
	$("#paytansist>article>div>div>h1").text(Url["tit"]);
	$("#paytansist>article>div>div>h1").append("<span>"+"￥"+Url["jiage"]+"元"+"</span>");
	$("#paytansist>.zf>p").text("实付" + Url["jiage"] + "元");
	$("#quzhifu").attr("jiage", Url["jiage"]);
	$("#quzhifu").attr("quanid", "0");
	$("#quzhifu").attr("kechengid", "0");
	if(Url["kechengid"]) {
		$("#quzhifu").attr("kechengid", Url["kechengid"]);
		var dataid=Url["kechengid"];
	var lujing = luk + dataid + qb;
			$(".yubuzu>p>a").attr("href", lujing);
		}
    if(Url["peixunid"]){
    	$("#quzhifu").attr("kechengid", Url["peixunid"]);
    	var dataid=Url["peixunid"];
    	var lujing = lup + dataid + qb;
			$(".yubuzu>p>a").attr("href", lujing);
		}
	$("#twoquan>a").click(function() {
		new Ajax("/quan").keyvalue("amount",jiage).getJson(function(data) {
			$.each(data, function(key, val) {
				$("#payquan").find("ul").html("");
				$("#payquan").find("ul").html("<li><input type='radio' name='id' value='0' quanid='0'/>不使用优惠券</li>");
				$("#payquan").find("ul").append("<li><input type='radio' name='id' value=" + val["amount"] + " quanid=" + val["id"] + ">" + val["name"] + "</li>");
			});
			$("[name='id']").click(function() {
				var jinquan=$('input:radio[name="id"]:checked').val();
				var endjiage=jiage-jinquan;
				var quanid=$('input:radio[name="id"]:checked').attr("quanid");
				$("#payquan").hide();
				$("#paytansist").show();
				$("#paytansist>.zf>p").text("实付"+endjiage+"元");
				$("#quzhifu").attr("jiage", endjiage);
				$("#quzhifu").attr("quanid", quanid);
			});
		});
	});
   $("#twoquan>a").on("click",function(){
   $("#payquan").show();
   })

});